package snippet;

public class T11 {
	public static void main(String[] args) {
		int[] height= {1,8,6,2,5,4,8,3,7};
		System.out.println(new T11().maxArea(height));
	}
	 public int maxArea(int[] height) {
		 int max=0 ,l=0,r=height.length-1;
		while (l<r) {
		
			
				max=Math.max(max, (Math.min(height[l],height[r]))*(r-l));
			if(height[l]<height[r]) {
				l++;
			}else {
				r--;
			}
		}
		return max;    
	    }
}
